// 用户类型
export interface User {
  id: number;
  username: string;
  email: string;
  nickname?: string;
  phone?: string;
  avatar?: string;
  role: 'admin' | 'user' | 'merchant';
  status: 'active' | 'inactive' | 'banned' | 'deleted';
  created_at?: string;
  updated_at?: string;
  last_login_at?: string;
}

// 菜单项类型
export interface MenuItem {
  key: string;
  label: string;
  icon?: string;
  path?: string;
  children?: MenuItem[];
  permission?: string;
  hidden?: boolean;
}

// 仪表盘统计数据类型
export interface DashboardStats {
  totalUsers: number;
  totalOrders: number;
  totalRevenue: number;
  monthlyGrowth: number;
}

// API响应类型
export interface ApiResponse<T = any> {
  success: boolean;
  message: string;
  data: T;
  timestamp?: string;
}

// 分页类型
export interface Pagination {
  page: number;
  limit: number;
  total: number;
  totalPages: number;
  hasNext: boolean;
  hasPrev: boolean;
}

// 分页响应类型
export interface PaginatedResponse<T = any> {
  list: T[];
  pagination: {
    current: number;
    pageSize: number;
    total: number;
    totalPages: number;
  };
}

// 新的API分页响应类型
export interface ApiPaginatedResponse<T = any> {
  success: boolean;
  message: string;
  data: {
    items: T[];
    pagination: {
      page: number;
      limit: number;
      total: number;
      totalPages: number;
      hasNext: boolean;
      hasPrev: boolean;
    };
  };
  timestamp?: string;
}

// AI对话记录专用的API响应类型
export interface AiChatApiResponse<T = any> {
  success: boolean;
  message: string;
  data: {
    records: T[];
    pagination: {
      page: number;
      limit: number;
      total: number;
      totalPages: number;
    };
  };
  timestamp?: string;
}

// 普通聊天记录专用的API响应类型
export interface ChatApiResponse<T = any> {
  success: boolean;
  message: string;
  data: {
    records: T[];
    pagination: {
      page: number;
      limit: number;
      total: number;
      totalPages: number;
    };
  };
  timestamp?: string;
}

// 表格查询参数
export interface QueryParams {
  page?: number;
  limit?: number;
  [key: string]: any;
}

// 用户查询参数
export interface UserQueryParams extends QueryParams {
  keyword?: string;
  status?: 'active' | 'inactive' | 'banned' | 'deleted';
  role?: 'admin' | 'user' | 'merchant';
  startDate?: string;
  endDate?: string;
}

// 创建用户请求
export interface CreateUserRequest {
  username: string;
  email: string;
  password: string;
  nickname?: string;
  role?: 'admin' | 'user' | 'merchant';
  status?: 'active' | 'inactive';
  phone?: string;
}

// 更新用户请求
export interface UpdateUserRequest {
  username?: string;
  email?: string;
  nickname?: string;
  role?: 'admin' | 'user' | 'merchant';
  status?: 'active' | 'inactive' | 'banned';
  phone?: string;
}

// 重置密码请求
export interface ResetPasswordRequest {
  newPassword: string;
}

// 批量更新状态请求
export interface BatchUpdateStatusRequest {
  ids: number[];
  status: 'active' | 'inactive' | 'banned';
}

// 用户统计数据
export interface UserStatistics {
  overview: {
    total_users: number;
    active_users: number;
    inactive_users: number;
    banned_users: number;
    admin_users: number;
    regular_users: number;
    new_users_week: number;
    new_users_month: number;
    active_users_week: number;
  };
  dailyRegistrations: Array<{
    date: string;
    user_count: number;
  }>;
}

// 主题类型
export type Theme = 'light' | 'dark';

// 语言类型
export type Language = 'zh-CN' | 'en-US';

// 应用配置类型
export interface AppConfig {
  theme: Theme;
  language: Language;
  collapsed: boolean;
}

// 服务器信息类型
export interface ServerInfo {
  hostname: string;
  platform: string;
  distro: string;
  arch: string;
  uptime: number;
  cpu: {
    manufacturer: string;
    brand: string;
    cores: number;
    physicalCores: number;
    speed: number;
    speedMax: number;
    load: {
      currentLoad: number;
      avgLoad: number;
      cpus: Array<{
        load: number;
        loadUser: number;
        loadSystem: number;
        loadIdle: number;
      }>;
    };
  };
  memory: {
    total: number;
    free: number;
    used: number;
    available: number;
    usagePercent: string;
    swapTotal: number;
    swapUsed: number;
    swapFree: number;
  };
  disk: Array<{
    fs: string;
    type: string;
    size: number;
    used: number;
    available: number;
    usagePercent: number;
    mount: string;
  }>;
  network: Array<{
    iface: string;
    ip4: string;
    ip6: string;
    mac: string;
    speed: number;
    type: string;
  }>;
  processes: {
    all: number;
    running: number;
    blocked: number;
    sleeping: number;
    list: Array<{
      pid: number;
      name: string;
      command: string;
      cpu: number;
      mem: number;
      state: string;
    }>;
  };
  database: any;
  docker?: {
    containers: number;
    containersRunning: number;
    containersPaused: number;
    containersStopped: number;
    images: number;
  };
  timestamp: number;
  updateTime: string;
}

// WebSocket消息类型
export interface WebSocketMessage {
  type: string;
  data: any;
}

// ===== 聊天管理相关类型 =====

// AI对话记录类型
export interface AiChatRecord {
  id: number;
  user_id: number;
  session_id: string;
  message_type: 'user' | 'assistant' | 'system';
  content: string;
  created_at: string;
  updated_at: string;
  username?: string;
  email?: string;
  nickname?: string;
}

// AI对话查询参数
export interface AiChatQueryParams extends QueryParams {
  user_id?: number;
  session_id?: string;
  message_type?: 'user' | 'assistant' | 'system';
  keyword?: string;
  start_date?: string;
  end_date?: string;
  sort?: 'created_at_desc' | 'created_at_asc' | 'updated_at_desc' | 'updated_at_asc' | 'user_id_asc' | 'session_id_asc';
}

// AI对话统计信息
export interface AiChatStatistics {
  total: number;
  today: number;
  thisWeek: number;
  activeUsers: number;
  totalSessions: number;
  messageTypeStats: Array<{
    message_type: string;
    count: number;
  }>;
}

// 普通对话记录类型
export interface ChatRecord {
  id: number;
  user_id: number;
  message: string;
  message_type: 'user' | 'customer_service';
  room_id: string;
  is_read: boolean;
  created_at: string;
  updated_at: string;
  username?: string;
  email?: string;
  nickname?: string;
}

// 普通对话查询参数
export interface ChatQueryParams extends QueryParams {
  user_id?: number;
  room_id?: string;
  message_type?: 'user' | 'customer_service';
  is_read?: boolean;
  keyword?: string;
  start_date?: string;
  end_date?: string;
  sort?: 'created_at_desc' | 'created_at_asc' | 'updated_at_desc' | 'updated_at_asc' | 'user_id_asc' | 'room_id_asc';
}

// 普通对话统计信息
export interface ChatStatistics {
  total: number;
  today: number;
  thisWeek: number;
  unread: number;
  activeUsers: number;
  activeRooms: number;
  messageTypeStats: Array<{
    message_type: string;
    count: number;
  }>;
  topActiveRooms: Array<{
    room_id: string;
    message_count: number;
  }>;
}

// 批量删除请求
export interface BatchDeleteRequest {
  ids: number[];
} 